﻿@model WeProjectsModel.Resource

<style type="text/css">
    section.container form > div {
        margin-top: 10px;
        margin-bottom: 10px;
    }
</style>

@{
    ViewBag.Title = "Edit";
}

<h2>编辑资源</h2>
<p class="buttonIn">
    @Html.ActionLink("返回列表", "Index")
</p>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>

        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            <label class="control-label width-40p">标题</label>
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>
        <div class="form-group">
            <label class="control-label width-40p" style="vertical-align:top;">内容</label>
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="form-group">
            <label class="control-label width-40p">文件</label>
            @Html.DisplayFor(model => model.FileName)
            <div style="display:inline-block;margin-left:10px;"><input type="file" name="file_upload" id="file_upload" /></div>
        </div>

        <div class="form-group">
            <label class="control-label width-40p"></label>
            <input type="submit" value="保存" class="btn btn-success" />
        </div>
    </fieldset>
}


@section Styles{
    <link href="@Href("~/Content/uploadify.css")" rel="stylesheet" />
}
@section scripts{
    <script src="@Href("~/Scripts/jquery.uploadify.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var recourceID =@Model.ID
        $(function () {
            $('#file_upload').uploadify({                
                'fileSizeLimit':0,
                'swf': '@Url.Content("~/Scripts/uploadify.swf")',
                'uploader': '@Url.Content("~/Resource/ChangeFile")',
                'auto': true,
                'fileSizeLimit': 0,
                'multi': false,
                'formData': { 'recourceID': recourceID },
                'buttonText': '更改附件',
                'cancelImg': '@Url.Content("~/images/uploadify-cancel.png")',
                'onQueueComplete' : function(file, data, response) {
                    //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                    if (response != "OK")
                    {
                        //alert('The file ' + file.name + ' was failed to upload with a response of ' + response + ':' + data);
                    }
                    location.reload(true);
                }
            });
        });
</script>
}



